package com.example.mobile2121606109ycg0407;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivityTip3 extends AppCompatActivity {

    private EditText edtTxtMain35;
    private TextView tvMain3Result;
    private Button btnMain3Result;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_tip3);
        initView();

        btnMain3Result.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //获取输入的五位字符串
                String txt = edtTxtMain35.getText().toString();
                //进行后四位的变化
                char s[] =txt.toCharArray();
                String c1 = null,c2 = null,c3 = null,c4 = null,c5 = null;
                for(int i = 0; i < s.length; i++){
                        char c = (char)(s[i]+4);
                        switch (i){
                            case 0:
                                c1 = String.valueOf(c);
                                break;
                            case 1:
                                c2 = String.valueOf(c);
                                break;
                            case 2:
                                c3 = String.valueOf(c);
                                break;
                            case 3:
                                c4 = String.valueOf(c);
                                break;
                            case 4:
                                c5 = String.valueOf(c);
                                break;
                        }
                }
                tvMain3Result.setText(c1+c2+c3+c4+c5);
            }
        });
    }

    private void initView() {
        edtTxtMain35 = (EditText) findViewById(R.id.edtTxtMain3_5);
        tvMain3Result = (TextView) findViewById(R.id.tvMain3_Result);
        btnMain3Result = (Button) findViewById(R.id.btnMain3_Result);
    }
}